

import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/* Router Modules */
// import componentsRouter from './modules/components'

import operationRouter from './modules/sys/operation'
import maintainRouter from './modules/sys/maintain'
import codegen from './modules/sys/codegen'
import configRouter from '@/router/modules/customer/configRouter'

import imgentityRouter from './modules/customer/game/imgentityRouter'
import softwarecategoryRouter from './modules/customer/game/softwarecategoryRouter'
import softwarerankingsRouter from './modules/customer/game/softwarerankingsRouter'
import appcorrelationRouter from './modules/customer/game/appcorrelationRouter'
import softwaregroupRouter from './modules/customer/game/softwaregroupRouter'
import softwaregroupsetRouter from './modules/customer/game/softwaregroupsetRouter'
import userentityRouter from './modules/customer/game/userentityRouter'
import impushRouter from './modules/customer/game/impushRouter'
import feedbackRouter from '@/router/modules/customer/game/feedbackRouter'
import messageentityRouter from '@/router/modules/customer/game/messageentityRouter'
import friendscircleRouter from '@/router/modules/customer/game/friendscircleRouter'
import robotUserRouter from '@/router/modules/customer/game/robotUserRouter'
import softwareh5Router from '@/router/modules/customer/game/softwareh5Router'
import softwareiosRouter from '@/router/modules/customer/game/softwareiosRouter'
import softwareandroidRouter from '@/router/modules/customer/game/softwareandroidRouter'
import marketRouter from '@/router/modules/customer/game/marketRouter'
import chatRouter from '@/router/modules/customer/game/chatRouter'
import reportDetailRouter from '@/router/modules/customer/game/reportDetailRouter'
import userreportRouter from '@/router/modules/customer/game/userreportRouter'

import appinfoRouter from '@/router/modules/customer/wxad/appinfoRouter'
import bannerRouter from '@/router/modules/customer/wxad/bannerRouter'
import categoryRouter from '@/router/modules/customer/wxad/categoryRouter'
import cdkRouter from '@/router/modules/customer/wxad/cdkRouter'
import contentinfoRouter from '@/router/modules/customer/wxad/contentinfoRouter'

import terminalRouter from '@/router/modules/customer/term/terminalRouter'
import terminalreportRouter from '@/router/modules/customer/term/terminalreportRouter'


import actorauthRouter from '@/router/modules/customer/playlet/actorauthRouter'
import hotwordsRouter from '@/router/modules/customer/playlet/hotwordsRouter'
import levelRouter from '@/router/modules/customer/playlet/levelRouter'
import livingRouter from '@/router/modules/customer/playlet/livingRouter'
import userworksRouter from '@/router/modules/customer/playlet/userworksRouter'
import topicRouter from '@/router/modules/customer/playlet/topicRouter'
import loginuserRouter from '@/router/modules/customer/loginuserRouter'
import tipoffRouter from '@/router/modules/customer/playlet/tipoffRouter'
import goodsRouter from '@/router/modules/customer/appad/goodsRouter'
import loginusertermRouter from '@/router/modules/customer/appad/loginusertermRouter'
import withdrawlogRouter from '@/router/modules/customer/appad/withdrawlogRouter'
import withdrawaccountRouter from '@/router/modules/customer/appad/withdrawaccountRouter'
import orderRouter from '@/router/modules/customer/appad/orderRouter'
import coinchangelogRouter from '@/router/modules/customer/appad/coinchangelogRouter'
import deviceadincomeRouter from '@/router/modules/customer/appad/deviceadincomeRouter'
import deviceRouter from '@/router/modules/customer/appad/deviceRouter'
import riskassessmentRouter from '@/router/modules/customer/appad/riskassessmentRouter'
import taskRouter from '@/router/modules/customer/appad/taskRouter'
import withdrawgoodsRouter from '@/router/modules/customer/appad/withdrawgoodsRouter'
import orginfoRouter from '@/router/modules/customer/appad/orginfoRouter'
import devicewalletRouter from '@/router/modules/customer/appad/devicewalletRouter'
import coinReportRouter from '@/router/modules/customer/appad/CoinReportRouter'
import reservationRouter from "@/router/modules/customer/kaoshi/reservationRouter";
import reservationrecordRouter from "@/router/modules/customer/kaoshi/reservationrecordRouter";
import receiveRouter from "@/router/modules/customer/router/receiveRouter";
import submitRouter from "@/router/modules/customer/router/submitRouter";
import tasksRouter from "@/router/modules/customer/router/taskRouter";



/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    noCache: true                if set true, the page will no be cached(default is false)
    affix: true                  if set true, the tag will affix in the tags-view
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 *
 */

export const constantRoutes = [
  // 商品
  // storeRouter,
  // // 订单
  // orderRouter,
  // // 会员
  // userRouter,
  // // 分销
  // distributionRouter,
  // // 营销
  // marketingRouter,
  // // 财务
  // financialRouter,
  // // 内容
  // contentRouter,
  // 设置
  operationRouter,
  // 应用
 // appSettingRouter,
  // 维护
  maintainRouter,
  //移动端管理
  //mobileRouter,
  // 代码生成
  //codegen,

  //game
  // imgentityRouter,
  // softwareandroidRouter,
  // softwarecategoryRouter,
  // softwarerankingsRouter,
  // appcorrelationRouter,
  // softwaregroupRouter,
  // softwaregroupsetRouter,
  // userentityRouter,
  // impushRouter,
  // feedbackRouter,
  // messageentityRouter,
  // friendscircleRouter,
  // robotUserRouter,
  // softwareh5Router,
  // softwareandroidRouter,
  // softwareiosRouter,
  // marketRouter,
  // chatRouter,
  // reportDetailRouter,
  // userreportRouter,
  // topicRouter,

//customer
  configRouter,
//jdy
  terminalRouter,
  terminalreportRouter,


//wxad
  appinfoRouter,
  bannerRouter,
  categoryRouter,
  cdkRouter,
  contentinfoRouter,
//playlet
  actorauthRouter,

  hotwordsRouter,
  levelRouter,
  livingRouter,

  topicRouter,
  userworksRouter,
  // loginuserRouter,
  tipoffRouter,
  reservationRouter,
  reservationrecordRouter,
  receiveRouter,
  submitRouter,
  tasksRouter,
//sys
//appad
  orderRouter,
  withdrawaccountRouter,
  withdrawlogRouter,
  loginusertermRouter,
  goodsRouter,
  coinchangelogRouter,
  deviceadincomeRouter,
  deviceRouter,
  riskassessmentRouter,
  taskRouter,
  withdrawgoodsRouter,
  orginfoRouter,
  devicewalletRouter,
  coinReportRouter,
  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  },
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  // {
  //   path: '/auth-send',
  //   component: () => import('@/views/mobile/auth-send'),
  //   hidden: true
  // },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/auth-redirect'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error-page/401'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/dashboard/index'),
        name: 'Dashboard',
        meta: { title: '主页', icon: 'dashboard', affix: true }
      },
    ]
  },
  {
    path: '/setting/uploadPicture',
    component: () => import('@/components/uploadPicture/index.vue'),
    name: 'uploadPicture'
  },
  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [

]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  mode: 'history',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
